﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

using DeviceInfoManage.BusinessLogicLayer;

public partial class DeviceLendList : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["adminUserName"] == null)
        {
            Response.Redirect("login.aspx");
        }

    }

    protected void Btn_Query_Click(object sender, EventArgs e)
    {
        /*取得各个查询字段的内容然后调用业务类的QueryLendInfo函数进行查询*/
        string deviceName = this.DeviceName.Text;
        string deviceType = this.DeviceType.Text;
        string startTime = this.StartTime.Text;
        string endTime = this.EndTime.Text;

        this.GridView1.DataSourceID = null;
        this.GridView1.DataSource = (new LendInfo()).QueryLendInfo(deviceName, deviceType, startTime, endTime);
        this.GridView1.DataBind();
    }
    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            //当鼠标选择某行时变颜色
            e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#00ffee';");
            e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c;");
            e.Row.Cells[4].Text = Convert.ToDateTime(e.Row.Cells[4].Text).ToShortDateString();
        }
    }
}
